<?php
namespace App\Http\Controllers\Index;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Qiniu\Auth;
use Qiniu\Cdn\CdnManager;
use Qiniu\Storage\BucketManager;

class QiniuController extends Controller
{

    /**
     * @OA\Post(
     *     path="/admin/minerToken",
     *     tags={"矿机"},
     *     summary="附件上传token",
     *     @OA\Response(
     *         response="200",
     *         description="正常",
     *     )
     * )
     */
    public function up_token(){

        $bucket = 'dianduidian';
        $accessKey = 'snXv-ESA8trV6gPVFQLFqwdM2-qxwU1tBBkU1XTD';
        $secretKey = 'ALa8FB9Lo1lkWPbx4LaSK9Bzf8_qmn1WwWuurdi8';
        $auth = new Auth($accessKey, $secretKey);
        $size = 10 * 1024 *1024;  //10M
        $policy = [
            'fsizeLimit' => $size,
            'saveKey' => 'finger/'.date('Y-m-d').'/'.rand(10000,55555).'$(ext)',
        ];
        $key = null;
        $expires = 3600;
        $upToken = $auth->uploadToken($bucket,$key,$expires,$policy);
        return s_msg('',$upToken);
    }


}


